--[[
 -- *名称:MissileTypeAnalyzer
 -- *描述:火箭
 -- *版权:Copyright © 2016-2018 深圳市三只小熊科技有限公司 版权所有
 -- *作者:Administrator
 -- *创建日期:2017-11-10
 -- *修改日期:2017-11-10
 ]]
local DdzSuitAnalyzer = require(basePath.."suit/ddzsuitanalyzer");
local MissileTypeAnalyzer = pokercore.class(DdzSuitAnalyzer,false);

local TUPLE_SIZE = 2 ;

function MissileTypeAnalyzer:getSuitType()
	return DdzCardTypes.MISSILE;
end

--@Override
function MissileTypeAnalyzer:sort(cards,  term)
	PokerUtil.sortCards_desc(cards);-- // 大王在前小王在后
end

--@Override
function MissileTypeAnalyzer:doCheckRule( cards, term, result )
	if (result:getCardNum() == TUPLE_SIZE) then
		return result:getNoneLaziValueCounter():getValueCount(PokerGameConstant.BLACK_JOKER_SHAPE_NUM) == 1
				and result:getNoneLaziValueCounter():getValueCount(PokerGameConstant.RED_JOKER_SHAPE_NUM) == 1;
	else 
		return false;
	end
end


--@Override
function MissileTypeAnalyzer:doAnalysizeLaizi(cards,term,onlyMaxValue)
	local cardsResult = {}
	for _,card in ipairs(cards) do -- // 设置number
		card:changeCard(card:getNumber());
	end
	local cardsCopy = cards:clone();
	self:analysize(cardsCopy, term);
	table.insert(cardsResult,cardsCopy:clone());
	return cardsResult;
end

--提牌列表
	
--@Override
function MissileTypeAnalyzer:containsPossibleCards(handCards, term) 
	local result = handCards:getResult();
	return result:getNoneLaziValueCounter():getValueCount(PokerGameConstant.BLACK_JOKER_SHAPE_NUM) == 1
			and result:getNoneLaziValueCounter():getValueCount(PokerGameConstant.RED_JOKER_SHAPE_NUM) == 1;
end
	
--@Override
function MissileTypeAnalyzer:doListPossibleCards(handCards,term) 
	local cardsResult = {};
	local missileCardList = {};
	table.addAll(missileCardList,DdzTypeUtil.cloneObtainedCards(handCards, PokerGameConstant.RED_JOKER_SHAPE_VALUE, 1));
	table.addAll(missileCardList,DdzTypeUtil.cloneObtainedCards(handCards, PokerGameConstant.BLACK_JOKER_SHAPE_VALUE, 1));
	local cardsCopy = DdzTypeUtil.createCardsCopy(missileCardList);
	if (self:match(cardsCopy, term)) then
		self:analysize(cardsCopy, term);
		table.insert(cardsResult,cardsCopy:clone());
	end
	return cardsResult;
end

return MissileTypeAnalyzer;

